home *** CD-ROM | disk | FTP | other *** search
- property pNetID, pNetDone, pCurrentAttempt, pMaxAttempts, pTextResult, pmode, pURL, pCallBackMethod, pPropertyList, pCallBackObject, pLocalFile
- global gNetQueue, gTracker
-
- on new me, mode, url, callBackMethod, callBackObject, propertyList, localFile
- pMaxAttempts = 3
- pNetDone = 1
- pmode = mode
- pURL = url
- pCallBackMethod = callBackMethod
- pPropertyList = propertyList
- pCallBackObject = callBackObject
- pLocalFile = localFile
- return me
- end
-
- on mDestruct me
- pCallBackObject = 0
- end
-
- on mExecuteNetCommand me
- case pmode of
- #GET:
- pNetID = getNetText(pURL)
- #POST:
- pNetID = postNetText(pURL, pPropertyList)
- #preload:
- pNetID = preloadNetThing(pURL)
- #download:
- pNetID = downloadNetThing(pURL, pLocalFile)
- end case
- pCurrentAttempt = 1
- pNetDone = 0
- end
-
- on mCallBackResults me
- if pCallBackMethod.ilk <> #void then
- if pCallBackObject.ilk = #void then
- do(pCallBackMethod && "(" & QUOTE & pTextResult & QUOTE & ")")
- else
- call(pCallBackMethod, pCallBackObject, pTextResult)
- end if
- end if
- end
-
- on mIsNetOpDone me
- if netDone(pNetID) then
- if netError(pNetID) = "OK" then
- case pmode of
- #GET, #POST:
- pTextResult = netTextResult(pNetID)
- otherwise:
- pTextResult = EMPTY
- end case
- pNetDone = 1
- else
- if pCurrentAttempt < pMaxAttempts then
- pCurrentAttempt = pCurrentAttempt + 1
- me.mExecuteNetCommand()
- else
- pTextResult = "net error:" && netError(pNetID)
- pNetDone = 1
- end if
- end if
- end if
- return pNetDone
- end
-